/*
  学习目标：props设置默认值
*/
import React from 'react';

export default class App extends React.Component {
  render() {
    return (
      <div>
        <Child></Child>
        <NewChild></NewChild>
      </div>
    );
  }
}
// 👍函数式组件, 可以通过形参, 给props添加初始值
function NewChild({ count = 0, msg = 'hello React' }) {
  console.log('count  ----->  ', count, msg);

  return (
    <h1>
      NewChild- {count} - {msg}
    </h1>
  );
}

function Child({ count, msg }) {
  return (
    <h1>
      Child - {count} - {msg}
    </h1>
  );
}

// 早期给组件增加默认值的方式: class组件用法相同
Child.defaultProps = {
  count: 100,
  msg: 'hello React',
};
